package com.yjq.programmer.controller.app;

import com.yjq.programmer.dto.AlbumDTO;
import com.yjq.programmer.dto.PageDTO;
import com.yjq.programmer.dto.ResponseDTO;
import com.yjq.programmer.service.IAlbumService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 杨杨吖
 * @QQ 823208782
 * @WX yjqi12345678
 * @create 2022-11-17 21:26
 */
@RestController("AppAlbumController")
@RequestMapping("/app/album")
public class AlbumController {

    @Resource
    private IAlbumService albumService;

    /**
     * 小程序根据专辑分类id获取专辑数据
     * @param albumDTO
     * @return
     */
    @PostMapping("/getByCategoryId")
    public ResponseDTO<List<AlbumDTO>> appGetAlbumByCategoryId(@RequestBody AlbumDTO albumDTO) {
        return albumService.getAlbumByCategoryId(albumDTO);
    }

    /**
     * 小程序根据专辑id获取专辑数据
     * @param albumDTO
     * @return
     */
    @PostMapping("/getById")
    public ResponseDTO<AlbumDTO> appGetById(@RequestBody AlbumDTO albumDTO) {
        return albumService.getById(albumDTO);
    }

    /**
     * 小程序搜索专辑
     * @param albumDTO
     * @return
     */
    @PostMapping("/search")
    public ResponseDTO<List<AlbumDTO>> appSearchAlbum(@RequestBody AlbumDTO albumDTO) {
        return albumService.searchAlbum(albumDTO);
    }

    /**
     * 小程序获取热门专辑数据
     * @param pageDTO
     * @return
     */
    @PostMapping("/hot")
    public ResponseDTO<List<AlbumDTO>> appGetHotAlbumList(@RequestBody PageDTO<AlbumDTO> pageDTO) {
        return albumService.getHotAlbumList(pageDTO);
    }

    /**
     * 小程序专辑浏览量增加
     * @param albumDTO
     * @return
     */
    @PostMapping("/addView")
    public ResponseDTO<Boolean> appAddAlbumView(@RequestBody AlbumDTO albumDTO) {
        return albumService.addAlbumView(albumDTO);
    }

}
